// 1.导入axios
import axios from "axios";
// 2.创建axios
const _axios = axios.create({
    baseURL: 'https://sports.nplusc.cn',
});
// 3.请求拦截器
_axios.interceptors.request.use(
    (config) => {
        config.headers['x-access-token'] = 'cdn3UdW8ioSkskW211AAPVyLzZOuZy2S'
        return config;
    },
    (error) => {
        console.log(error, "请求失败之后的结果");
        return Promise.reject(error);
    }
);
// 4.响应拦截器
_axios.interceptors.response.use(
    (res) => {
        if (res.data.code == 0) {
            return res.data;
        } else {
            // 错误的提示信息
            return Promise.reject(res.data.message);
        }
    },
    (error) => {
        return error, "响应失败的结果";
    }
);
export default _axios;